﻿#include <FlexLexer.h>
#include <fstream>
#include <string>
#include <vector>

using namespace std;

// int yywrap() {
//     // open next reference or source file and start scanning
//     if ((yyin = compiler->getNextFile()) != NULL) {
//         line = 0; // reset line counter for next source file
//         return 0;
//     }
//     return 1;
// }

extern std::string formula_name;
extern std::vector<std::string> params;

int main(int argc, char **argv) {
    if (argc == 1) {
        printf("usage:%s [file]", argv[0]);
        return 1;
    }
    ifstream *pmyFile = new ifstream();
    pmyFile->open(argv[1], ios::out);
    if (pmyFile->fail()) {
        printf("error while open the file");
        return 1;
    }
    FlexLexer *lexer = new yyFlexLexer(pmyFile);
    while (lexer->yylex() != 0)
        ;
    // printf("total lines:%d/ntotal chars:%d/n", num_lines, num_chars);
    cout << endl;
    cout << "formula_name:" << formula_name << endl;
    for (auto &&p : params) {
        cout << p << endl;
    }

    delete pmyFile;
    delete lexer;
    return 0;
}